<template>
	<view class="rank">
		<u-tabs :list="tabList" name="item_name" :is-scroll="false" :current="current" @change="change"></u-tabs>
		<view class="flex statistic__date">
			<view class="statistic__date-text u-margin-20 u-font-15" @click="showDate = true">{{date}}</view>

			<u-icon name="arrow-down-fill" size="30"></u-icon>
		</view>
		<view class="" v-for="(item,index) in itemList">
			<view class="">
				{{item.changeTypeName}}
			</view>
		</view>
		<u-picker v-model="showDate" mode="time" :params="params" @confirm="confirm"></u-picker>
	</view>
</template>
<script>
	export default {
		data() {
			return {

				tabList: [{
					item_name: '分润账户',
					value: 'POS_PROFIT' //TRANS_AMOUNT

				}, {
					item_name: '返现账户',
					value: 'ACTIVE_PROFIT' //TRANS_COUNT
				}, {
					item_name: '流量卡账户',
					value: 'FLOW_PROFIT' //SN_COUNT

				}, {
					item_name: '其他账户', //SN_BING
					value: 'OTHER_PROFIT'
				}],
				current: 0,

				searchParams: {
					accountType: "POS_PROFIT", //list value
					searchMonth: "", //1 传这个


				},
				pageNo: 1,
				pageSize: "10",
				itemList: [],
				params: {
					year: true,
					month: true,
					day: false,
					hour: false,
					minute: false,
					second: false
				},
				date: "",
				showDate: false,
				year: "",
				month: "",
				day: ""
			}
		},
		onReachBottom() {
			this.onScrolltolower();
		},
		mounted() {
			this.date = this.traversalTime(new Date().getTime());

			this.searchParams.searchMonth = this.date;

			this.getList();
		},
		methods: {
			change(index) {
				this.current = index;
				this.searchParams.accountType = this.tabList[index].value;
				this.pageNo = "1";
				this.itemList = [];
				this.getList();
			},
			onPageScroll(e) {
				this.scrollTop = e.scrollTop;
			},
			onScrolltolower() {
				this.status = "loading";
				this.getList();
			},
			getList() {
				const _that = this;
				this.$zx.order_api.listAccountDetail(this.pageNo, this.pageSize, this.searchParams).then((data) => {

					console.log("data=" + JSON.stringify(data))
					_that.itemList = _that.itemList.concat(data);
					// console.log("data=" + JSON.stringify(_that.terminalList))
					if (data.length !== 0) {
						this.status = "loadmore";
						this.pageNo += 1;
					} else {
						this.status = "nomore";
					}
				});
			},
			traversalTime(timestamp) {
				//timestamp(时间戳)是整数，否则要parseInt转换
				let time = new Date(timestamp);
				let y = time.getFullYear();
				let m = time.getMonth() + 1;
				let d = time.getDate();
				let h = time.getHours();
				let mm = time.getMinutes();
				let s = time.getSeconds();
				this.year = y;
				this.month = this.addTimes(m);
				this.day = this.addTimes(d);
				return y + '-' + this.addTimes(m);
			},
			addTimes(m) {
				return m < 10 ? '0' + m : m
			},
			confirm(object) {
				console.log("o=" + JSON.stringify(object))
				this.searchParams.searchMonth = object.year + "-" + object.month;
				this.pageNo = "1";
				this.itemList = [];
				this.getList();
			}
		}
	}
</script>
<style>
</style>